﻿function Point(x, y) {
    this.X = x;
    this.Y = y;

    this.Distance = function (pointA, pointB) {

        if (pointB == null)
            pointB = this;

        if (pointA == null || pointB == null)
            return -1;

        return Math.sqrt((pointB.X - pointA.X) * (pointB.X - pointA.X) + (pointB.Y - pointA.Y) * (pointB.Y - pointA.Y));

    };

    this.Round = function () {
        return new Point(Math.round(this.X), Math.round(this.Y));
    };

};